1. Field of the Invention
The present invention relates to encoding devices and methods using both run-length encoding and variable-length encoding, and in particular relates to encoding devices and methods in which image compression technologies for compressing image data are used.
2. Description of the Related Art
Encoding methods using run-length encoding and variable-length encoding are employed by JPEG (Joint Photographic Experts Group) and MPEG (Moving Picture Experts Group), which are general compression technologies for image data, and with the popularity of digital cameras and digital video cameras and the advances in communications technology, for example, these encoding methods have become widespread as technologies that allow data to be transferred in small information amounts.
FIG. 30 shows a representative configuration of a conventional image compression device. In FIG. 30, a DCT (discrete cosine transform) portion 801 performs frequency conversion with respect to image data that have already been separated into 8×8 units per block and received in order, creating DCT coefficients.
In general, the change in color in the majority of natural images is smooth. Consequently, in a DCT coefficient distribution, such as that shown in FIG. 31, created by performing frequency conversion, DCT coefficients having large values are concentrated in the low frequency region f and DCT coefficients having small values are distributed over the high frequency region g.
With respect to the DCT coefficients that are created, a quantizing portion 802 creates quantized coefficients by dividing the DCT coefficients by a quantizing value set in advance. Performing this processing allows the quantized coefficients to be concentrated in such a manner that the values in the high frequency region g, which does not affect the picture quality, become 0 (zero).
Also, in an encoding portion 803, code words with different lengths are allocated according to the appearance ratio of the combinations of the number of data units having a value of 0 (zero) and the values of the quantized coefficients, thereby reducing the overall data volume.
FIG. 32 is a diagram showing the configuration of the encoding portion 803 in the conventional image compression device. In FIG. 32, the quantized coefficients for the 8×8 units of data per block that are input from an input portion 804 are written to a data buffer 805 under the control of a write control portion 806, and are read out sequentially from the data buffer 805 under the control of a read control portion 807 through a zig-zag scan like that shown in FIG. 4.
With a run-length encoding portion 808, a comparing and determining portion 811 determines whether the quantized coefficients read out sequentially by the read control portion 807 are 0 (zero), and if a quantized coefficient is 0 (zero), then the number of quantized coefficients is counted by a run-length counter 812, and if there are none that are 0 (zero), then the run-length counter 812 is initialized to ‘0’. Then, a LEVEL signal that indicates the value of the quantized coefficient read out when the quantized coefficient is not 0 (zero) and a RUN signal that indicates the current number of quantized coefficients that are 0 (zero) that have been counted are output.
A variable-length encoding portion 809 performs variable-length encoding using the RUN signal and the LEVEL signal, which are the signals output by the run-length encoding portion 808, and outputs the encoded data.
With the configuration described above, however, encoding is carried out using both the LEVEL signal and the RUN signal. Consequently, encoding cannot be performed by the variable-length encoding portion 809 while consecutive quantized coefficients having a value of 0 (zero) are read out and the number of these consecutive quantized coefficients is counted by the run-length counter 812. For this reason, a waiting time occurs during the encoding process, leading to the problem that the speed of the overall encoding process cannot be increased.
Image compression devices such as that disclosed in JP 2000-50271A have been proposed as one solution to this problem.
In JP 2000-50271A, as shown in FIG. 33, DCT coefficients CF1 that have been quantized by a DCT/quantizing portion 21 are output. Also, a run-length counter 23 sets a zero flag ZF to ‘1’ if the DCT coefficient CF1 is 0 (zero) and sets the zero flag ZF to ‘0’ (zero) if the DCT coefficient CF1 is not 0 (zero).
A run-length RL1 indicates the number of consecutive values of 0 (zero) of the DCT coefficients CF1. Run-length encoding is carried out by finding the run-length RL1. That is, a run-length counter 23 corresponds to the run-length encoding portion 808 in FIG. 32 for finding the run-length.
A buffer controller 24 writes write data WD into an address WA of a buffer 22 in accordance with the zero flag ZF, the run-length RL1, and the DCT coefficient CF1.
If the DCT coefficient is not 0 (zero), then the write data WD is made of a most significant bit that is a zero flag=‘0’ (zero) and the CF1.
If the DCT coefficient is 0 (zero), then the write data WD is made of a most significant bit that is the zero flag=‘1’ and the run-length RL1.
If the zero flag ZF is consecutively ‘1’, that is, if the DCT coefficient CF1 is consecutively ‘0’ (zero), then, due to the address WA not changing, write data that is ultimately made of a zero flag=‘1’ and the run-length RL1 can be stored only in one address.
The buffer controller 24 reads out data RD from the address RA of the buffer 22, and supplies the run-length RL2 and the DCT coefficient CF2 as one data set to a variable-length encoding portion 25.
With the image compression device disclosed in JP 2000-50271A, however, although the problem of not being able to continue the encoding process while consecutive quantized coefficients having a value of 0 (zero) are read out and the number of consecutive quantized coefficients is counted by the run-length counter 23 is solved, there are still the processes of writing the run-length RL1 to the buffer and reading the run-length RL2 from the buffer, and until the process of reading and writing the number of consecutive quantized coefficients having a value of 0 (zero) to and from the buffer is over, the encoding process cannot be carried out by the variable-length encoding portion 25. That is, although the time is shortened, a waiting period still occurs like in the conventional example, and thus the problem that a further increase in the overall speed of the encoding process cannot be achieved remains.